package com.nd.te.test;

import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class globalterror implements WritableComparable<globalterror> {
    private String country;
    private int iyear;
    private int attack;

    public void set(String first, int second, int third) {
        this.country = first;
        this.iyear = second;
        this.attack=third;
    }

    public String toString(){
        return country+","+
               iyear+","+
               attack;

    }
    public String getCountry(){
        return this.country;
    }

    public int getIyear(){
        return this.iyear;
    }

    public int getAttack()
    {
        return this.attack;
    }


    @Override
    public int compareTo(globalterror o) {
        if (this.getIyear() > o.getIyear()){
            return 1;
        }else if(this.getIyear() < o.getIyear()){
            return -1;
        }

        int i = 0;
        if (o instanceof globalterror) {
            globalterror cc = (globalterror) o;
            return this.country.compareTo(cc.country);
        }
        return i;
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeUTF(country);
        dataOutput.writeInt(iyear);
        dataOutput.writeInt(attack);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        country= dataInput.readUTF();
        iyear=dataInput.readInt();
        attack=dataInput.readInt();
    }
}